package com.wmx.main;

import com.wmx.entity.MyCallable;

import java.util.concurrent.*;

/**
 * @author:wmx 2025-03-10 10:42
 * 1、功能:
 * 2、参数{
 * <p>
 * <p>
 * }
 **/
public class entrance {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        // 第二：工具类Executors创建线程池并返回ExecutorService对象
        //1、创建固定大小的线程池，包含 10 个线程
        ExecutorService executorService = Executors.newFixedThreadPool(10) ;
        //2、把new MyCallable()放在线程池中使用而且返回一个实例Future<Integer>
        Future<Integer> future = executorService.submit(new MyCallable());

        Integer integer = future.get();
        System.out.println(integer);
        //停止服务
        executorService.shutdownNow();
    }
}
